package com.crm.finance.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.crm.model.ConsultInfoManage;
import com.crm.model.ConsultInfoManagePay;
import com.crm.service.ConsultInfoManageService;
import com.crm.util.JsonUtil;
import com.crm.util.ResponseUtil;
import com.github.pagehelper.Page;

/**
 * @author 
 *
 * 集团财务应收款
 *
 */
@Controller
@RequestMapping("/financeGroupReceivable")
public class FinanceGroupReceivableController {
	
	@Autowired
	private ConsultInfoManageService service;
	
	@RequestMapping("/index")
	public String index(){
		
		return "financeCenter/groupReceivable";
	}
	
	@RequestMapping("/load")
	public void load(Page<ConsultInfoManage> page, ConsultInfoManage manage, HttpServletRequest request, HttpServletResponse response){
		Page<ConsultInfoManage> list = (Page<ConsultInfoManage>) service.selectFinanceGroupReceivableBalance(page, manage);
		ResponseUtil.resultPage(response, request, list);
	}
	
	@RequestMapping("/getTotalIncome")
	@ResponseBody
	public void getTotalIncome(ConsultInfoManage t, HttpServletRequest request, HttpServletResponse response){
		ConsultInfoManage manage = service.getReceivableTotalIncome(t);
		ResponseUtil.result(response, JsonUtil.toJsonStr(manage));
	}

	@RequestMapping("/getPayByInfoId")
	@ResponseBody
	public void getPayByInfoId(ConsultInfoManage t, HttpServletRequest request, HttpServletResponse response){
		List<ConsultInfoManagePay> list = service.getPayByInfoId(t.getInfoManageId());
		ResponseUtil.result(response, JsonUtil.toJsonStr(list));
	}
	
}
